<?php

namespace App\Modules\Admin\Services;

use Illuminate\Support\Facades\Storage;

class UploadService
{

    public function upload($param = null)
    {
        try {
            $filePath = "/public/upload/" . $param['module'] . '/' . date('Ym', time()) . '/' . date('d', time());

            $path = Storage::putFile($filePath, $param['file']);

            $result['path'] = request()->getSchemeAndHttpHost() . Storage::url($path);
            return $result;
        } catch (\Throwable $th) {
            throw $th;
        }
    }

}
